package com.ruoyi.write.controller;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.websocket.apiRequest;
import com.ruoyi.write.domain.Ad;
import com.volcengine.ark.runtime.model.completion.chat.ChatMessage;
import com.volcengine.ark.runtime.model.completion.chat.ChatMessageRole;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;
@RestController
@RequestMapping("/write")
public class AdController {
    @RequestMapping ("/ad")
    public AjaxResult ad(@RequestBody String text) {
        List<ChatMessage> messageList = new ArrayList<>();
        messageList.add(ChatMessage.builder().role(ChatMessageRole.USER).content(text).build());
        String request = apiRequest.request(messageList);
        return AjaxResult.success(request);
    }

}
